package com.endurance.strategy.factory;

import com.endurance.strategy.enums.PayEnumsStrategy;
import com.endurance.strategy.PayStrategy;

/**
 * @Author: sunlin
 * @Date: 2024-05-04 12:42
 * @Version: 1.0
 * @Description:
 */
public class StrategyFactory {

    public static PayStrategy getPayStrategy(String strategyType) {
        String className = PayEnumsStrategy.valueOf(strategyType).getClassName();
        try {
            // 获取具体的策略
            return (PayStrategy) Class.forName(className).newInstance();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

}
